package com.thinkfit.jy.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.common.lib.constant.Constants;
import com.common.lib.fragment.BaseFragment;
import com.common.lib.mvp.contract.EmptyContract;
import com.common.lib.mvp.presenter.EmptyPresenter;
import com.thinkfit.jy.R;
import com.thinkfit.jy.activity.SwitchMainStyleActivity;
import com.thinkfit.jy.utils.SportsStatusBarViewUtils;
import com.thinkfit.jy.view.OnInputListener;
import com.thinkfit.jy.view.VerifyCodeView;

import java.util.ArrayList;

/**
 * 管理模式界面
 */
public class AdminModeFragment extends BaseFragment<EmptyContract.Presenter> implements EmptyContract.View {

    TextView tv_1,tv_2,tv_3,tv_4;
    EditText etPassword;
    VerifyCodeView verifyCodeView;
    private String PASSWORD = "1234";
    ArrayList<TextView> tvs;

    public static AdminModeFragment getInstance(int index) {
        Bundle bundle = new Bundle();
        bundle.putInt(Constants.BUNDLE_EXTRA, index);
//        bundle.putInt(Constants.BUNDLE_EXTRA_2, type);
        AdminModeFragment fragment = new AdminModeFragment();
        fragment.setArguments(bundle);
        return fragment;
    }



    @Override
    protected int getLayoutId() {
        return R.layout.fragment_admin_mode;
    }

    @Override
    protected void initView(@NonNull View view, @Nullable Bundle savedInstanceState) {
//        tv_1 = view.findViewById(R.id.tv_1);
//        tv_2 = view.findViewById(R.id.tv_2);
//        tv_3 = view.findViewById(R.id.tv_3);
//        tv_4 = view.findViewById(R.id.tv_4);
        verifyCodeView = view.findViewById(R.id.verifyCodeView);
//        tvs = new ArrayList<>();
//        tvs.add(tv_1);
//        tvs.add(tv_2);
//        tvs.add(tv_3);
//        tvs.add(tv_4);
        verifyCodeView.setOnInputListener(new OnInputListener() {
            @Override
            public void onSuccess(@NonNull String code) {
                if (!code.equals(PASSWORD)) {
                    showToast(R.string.app_error_psw);
                    verifyCodeView.clearCode();
                    return;
                }
                openActivity(SwitchMainStyleActivity.class);
                verifyCodeView.clearCode();
                SportsStatusBarViewUtils.getInstance().visibleLayout();
//                finish();
            }

            @Override
            public void onInput() {

            }
        });


    }



    @Override
    public void onResume() {
        super.onResume();

    }

    @Override
    public void onStop() {
        super.onStop();
        System.out.println("ddddddddddddddddddddddd   AboutFragment ");
        SportsStatusBarViewUtils.getInstance().visibleLayout();
//        DeviceTypeUtils.showBackButton(getContext().getApplicationContext());
    }


    @NonNull
    @Override
    protected EmptyContract.Presenter onCreatePresenter() {
        return new EmptyPresenter(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {


        }
    }



}
